﻿using System.Windows;
using TorchView.Composition;
using TorchView.SharedStashEditor.ViewModels;
using TorchView.Windows;
using System;
using System.Windows.Controls;

namespace TorchView.SharedStashEditor.Views
{
    /// <summary>
    /// Interaction logic for AddItemView.xaml
    /// </summary>
    public partial class AddItemView : Window, IDialogView<IAddItemViewModel>
    {
        private WindowService _WindowService;

        private IAddItemViewModel _Model;

        public IAddItemViewModel Model
        {
            get { return _Model; }
            set { _Model = value; DataContext = value; }
        }

        public AddItemView()
        {
            InitializeComponent();
            _WindowService = new WindowService(this);
        }

        private void TextBox_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
        {
            if (sender != null)
            {
                TextBox text = (TextBox)sender;
                if (text.Text.Length > 0)
                    _Model.ItemId = long.Parse(text.Text);
            }
        }
    }
}
